<form class="tableform" method='post' action="<{link app=aftersales ctl='site_member' act='send_finish'}>" id="order-delivery-form">
<div class="member-main tk2">
<div class="title title2">退款退货管理</div>
    <{if $return_item.status == '退款协议等待卖家确认'}>
    <ul class="je_ac_limtime" id="timecount">
     <li><strong>距离同意申请还有：</strong></li>
     <li><a href="#" class="day">00</a>天</li>
     <li><a href="#" class="hour">00</a>小时</li>
     <li><a href="#" class="minute">00</a>分</li>
     <li><a href="#" class="second">00</a>秒</li>
     <div class="cl_zhi"></div>
    </ul>
    <{/if}>
    <{if $is_shop}>
    <ul class="je_ac_limtime" id="timecount">
     <li><strong>距离同意退款还有：</strong></li>
     <li><a href="#" class="day">00</a>天</li>
     <li><a href="#" class="hour">00</a>小时</li>
     <li><a href="#" class="minute">00</a>分</li>
     <li><a href="#" class="second">00</a>秒</li>
     <div class="cl_zhi"></div>
    </ul>
    <{/if}>
    <div class="note clearfix">
        <h3><{$return_item.title}></h3>
        <div class="clearfix">
            <div class="span-auto colborder pl10"><{t}>订单编号：<{/t}><span ><{$return_item.order_id}></span></div>
            <div class="span-auto colborder"><{t}>订单状态：<{/t}>
                <span >
                    <{$return_item.status}>
            </span></div>
            
            <{if $return_item.is_intervene == 2}>
                <div class="span-auto colborder"><{t}>平台介入，等待卖家举证<{/t}></div>
            <{/if}>
            <{if $return_item.is_intervene == 3}>
                <div class="span-auto colborder"><{t}>平台介入，等待平台审核<{/t}></div>
            <{/if}>
            <div class="span-auto last"><{t}>退货时间：<{/t}><span ><{$return_item.add_time|cdate:'FDATE_FTIME'}></span></div>
        </div>
       <!-- <{if $return_item.comment }>
        <{foreach from=$return_item.comment item="comment_item" name=comment}>
        <div class="division mt5 clearfix">
            <div class="border-bottom fontbold p2 clearfix textright">
                <span class="flt"><{t}>店主反馈<{/t}></span><span class="font12px font-gray fontnormal "><{$comment_item.time|cdate:'FDATE_FTIME'}></span></div>
            <p class="p2"><{$comment_item.content}></p>
        </div>
        <{/foreach}>
        <{/if}>-->
    </div>
    <h4 class="lineheight-30"><{t}>退款金额：<{/t}><span class="color1 font14px"><{$return_item.amount}>
    </span></h4>
    <h4 class="lineheight-30"><{t}>退款原因：<{/t}><span class="color1 font14px"><{if $return_item.safeguard_type && $return_item.is_safeguard == 2}><{$return_item.safeguard_type}><{else}><{$return_item.comment}><{/if}>
    </span></h4>
	<{if $return_item.product_data}>
    <h4 class="lineheight-30"><{t}>需要退货的商品<{/t}></h4>
    <table cellspacing="0" cellpadding="3" width="100%" class="gridlist border-all gridlist_member">
        <col class="span-4"></col>
        <col class="span-auto"></col>
        <col class="span-4"></col>
        <thead>
            <tr>
                <th class="first"><{t}>货号<{/t}></th>
                <th><{t}>商品名称<{/t}></th>
                <th><{t}>退货数量<{/t}></th>
            </tr>
        </thead>
        <tbody>
            <{if $return_item.product_data }>
            <{foreach from=$return_item.product_data item="product_item" name=product_data}>
            <tr>
                <td class="textcenter"><{$product_item.bn}></td>
                <td class="textcenter"><{$product_item.name}></td>
                <td class="textcenter"><{$product_item.num}></td>
            </tr>
            <{/foreach}>
            <{/if}>
        </tbody>
    </table>
    <{/if}>
    <{if $return_item.image_file || $return_item.image_file1 || $return_item.image_file2}>
    <h4><{t}>关于退货附件<{/t}></h4>
	<div class="thumbnailPic clearfix division">
	<{if $return_item.image_file}>		
			<a class="margin10" href="javascript:file_download()"><{t}>请点击下载该附件<{/t}></a>		
	<{/if}>
	<{if $return_item.image_file1}>
			<a class="margin10" href="javascript:file_download1()"><{t}>请点击下载该附件<{/t}></a>
	<{/if}>
	<{if $return_item.image_file2}>
			<a class="margin10" href="javascript:file_download2()"><{t}>请点击下载该附件<{/t}></a>
	<{/if}>
	</div>
    <{/if}>

    <{if $return_item.content}>
    <h4><{t}>详细说明<{/t}></h4>
    <div class="division">
        <{$return_item.content}>
    </div>
    <{/if}>

	<{if $return_item.refund_address}>
    <h4 class="lineheight-30"><{t}>退货地址<{/t}></h4>
    <div class="division">
        <{$address.region}>,<{$address.address}>,<{$address.uname}>,<{$address.phone}>,<{$address.mobile}>
    </div>
    <{/if}>

    <h4 class="lineheight-30"><{t}>退款记录<{/t}></h4>
    <{foreach from=$log_info item="log_info_item"}>
            <div class="division">
                <{if $log_info_item.role == 'member'}>我：<{elseif $log_info_item.role == 'seller'}>卖家：<{else}>管理员：<{/if}><{$log_info_item.log_text}><br/>
                日期：<{$log_info_item.alttime|cdate:'FDATE_FTIME'}>
            </div>
    <{/foreach}>
</div>
</form>
<script>
    function file_download(){
        var ifm=new IFrame({src:'<{link app=aftersales ctl=site_member act=file_download arg0=$return_id arg1=image_file}>'});
        ifm.inject(document.body);
    }
	function file_download1(){
        var ifm=new IFrame({src:'<{link app=aftersales ctl=site_member act=file_download arg0=$return_id arg1=image_file1}>'});
        ifm.inject(document.body);
    }
	function file_download2(){
        var ifm=new IFrame({src:'<{link app=aftersales ctl=site_member act=file_download arg0=$return_id arg1=image_file2}>'});
        ifm.inject(document.body);
    }
	function do_no_pass(){
		$('refuse').value = '1';
		$('order-delivery-form').submit();
	}
</script>
<{if $is_shop}>
<script>
    (function() {
        var timestamp_statues = (new Date()).valueOf();
        var timeCount=timestamp_statues;
        var timeCount = this.timeCount = {
            init:function(nowtime,endtime,dom){
                var diff = Math.abs((nowtime.getTime() - endtime.getTime())/1000);
                var secondDiff = diff % 60;
                var minuteDiff = ((diff - secondDiff)/60) % 60;
                var hourDiff = ((diff - secondDiff  - minuteDiff*60)/3600) % 24;
                var dayDiff = (diff - secondDiff  - minuteDiff*60 - hourDiff*3600) / 86400;
                var timeDiff = [dayDiff,hourDiff,minuteDiff,secondDiff];
                this.s = (function(){this.calcTime.periodical(1000,this,{
                        time:timeDiff,
                        dom:dom
                    })}).delay(100,this);
            },
            addZero:function(timeDiff){
                for(var i=0;i<timeDiff.length;i++){
                    if(timeDiff[i].toString().length<2){
                        timeDiff[i] = "0" + timeDiff[i].toString();
                        return timeDiff;
                    }
                }
            },
            formatToInt : function(timeDiff){
                for(var i=0;i<timeDiff.length;i++){
                    parseInt(timeDiff[i]);
                };
                return timeDiff;
            },
            judgeTime : function(timeDiff){
                if(timeDiff[3]< 0  && timeDiff[2]>0){
                    timeDiff[3] = 59;
                    timeDiff[2]--;
                    return timeDiff;
                }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]>0){
                    timeDiff[3] = 59
                    timeDiff[2] = 59;
                    timeDiff[1]--;
                    return timeDiff;
                }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]>0){
                    timeDiff[3] = 59
                    timeDiff[2] = 59;
                    timeDiff[1] = 23;
                    timeDiff[0]--;
                    return timeDiff;
                }else if(timeDiff[3]==0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]==0){
                    new Request.HTML({
                            url:'<{link app=business ctl=site_member act=js_function_do_refund_agrees}>',
                            method:'post',
                            data:'return_id=<{$return_item.return_id}>&order_id=<{$return_item.order_id}>'
                    }).send();
                    $clear(this.s);
                    $('timecount').innerHTML='<p>自动同意退款！</p>';
                    return;
                }
            },
            calcTime : function (obj){
                if(!obj.dom) return;
                var _timeDiff = obj.time;
                this.addZero(_timeDiff);
                this.formatToInt(_timeDiff);
                _timeDiff[3]--;
                this.judgeTime(_timeDiff);
                this.addZero(_timeDiff);
                var dom = obj.dom;
                dom.second.innerHTML = _timeDiff[3];
                dom.minute.innerHTML = _timeDiff[2];
                dom.hour.innerHTML = _timeDiff[1];
                dom.day.innerHTML = _timeDiff[0];
            },
            calcDesc:function(){
                new Request.HTML({
                        url:'<{link app=business ctl=site_member act=js_function_do_refund_agrees}>',
                        method:'post',
                        data:'return_id=<{$return_item.return_id}>&order_id=<{$return_item.order_id}>'
                }).send();
                $clear(this.s);
                $('timecount').innerHTML='<p>自动同意退款！</p>';
                return;
            }
        }
    })();
    (function(){
        var timeNow;
        var timeEnd= new Date(<{$time}>);
        var dom = {
            second: $E('.second'),
            minute:$E('.minute'),
            hour:$E('.hour'),
            day:$E('.day')
        };
        new Request({
            url:'<{$scarebuyings_data.js_url}>',
            onComplete:function(re){
                timeNow=new Date(<{$now_time}>); 
                if(timeEnd.getTime() > timeNow.getTime()){
                    timeCount.init(timeEnd,timeNow,dom);
                }else{
                    
                }
            }
        }).send();
    })();
 </script>
<{/if}>
<{if $return_item.status == '退款协议等待卖家确认' && $return_item.refund_type != '1'}>
    <{if $return_item.status == '退款协议等待卖家确认' && $return_item.refund_type = '2'}>
        <script>
        (function() {
            var timestamp_statues = (new Date()).valueOf();
            var timeCount=timestamp_statues;
            var timeCount = this.timeCount = {
                init:function(nowtime,endtime,dom){
                    var diff = Math.abs((nowtime.getTime() - endtime.getTime())/1000);
                    var secondDiff = diff % 60;
                    var minuteDiff = ((diff - secondDiff)/60) % 60;
                    var hourDiff = ((diff - secondDiff  - minuteDiff*60)/3600) % 24;
                    var dayDiff = (diff - secondDiff  - minuteDiff*60 - hourDiff*3600) / 86400;
                    var timeDiff = [dayDiff,hourDiff,minuteDiff,secondDiff];
                    this.s = (function(){this.calcTime.periodical(1000,this,{
                            time:timeDiff,
                            dom:dom
                        })}).delay(100,this);
                },
                addZero:function(timeDiff){
                    for(var i=0;i<timeDiff.length;i++){
                        if(timeDiff[i].toString().length<2){
                            timeDiff[i] = "0" + timeDiff[i].toString();
                            return timeDiff;
                        }
                    }
                },
                formatToInt : function(timeDiff){
                    for(var i=0;i<timeDiff.length;i++){
                        parseInt(timeDiff[i]);
                    };
                    return timeDiff;
                },
                judgeTime : function(timeDiff){
                    if(timeDiff[3]< 0  && timeDiff[2]>0){
                        timeDiff[3] = 59;
                        timeDiff[2]--;
                        return timeDiff;
                    }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]>0){
                        timeDiff[3] = 59
                        timeDiff[2] = 59;
                        timeDiff[1]--;
                        return timeDiff;
                    }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]>0){
                        timeDiff[3] = 59
                        timeDiff[2] = 59;
                        timeDiff[1] = 23;
                        timeDiff[0]--;
                        return timeDiff;
                    }else if(timeDiff[3]==0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]==0){
                        new Request.HTML({
                                url:'<{link app=business ctl=site_member act=js_function_do_refund_pass}>',
                                method:'post',
                                data:'return_id=<{$return_products.0.return_id}>&order_id=<{$return_item.order_id}>'
                        }).send();
                        $clear(this.s);
                        $('timecount').innerHTML='<p>自动同意申请！</p>';
                        $('scarebuyingprice').display='none';
                        $('scarebuyingsucc').display='';
                        return;
                    }
                },
                calcTime : function (obj){
                    if(!obj.dom) return;
                    var _timeDiff = obj.time;
                    this.addZero(_timeDiff);
                    this.formatToInt(_timeDiff);
                    _timeDiff[3]--;
                    this.judgeTime(_timeDiff);
                    this.addZero(_timeDiff);
                    var dom = obj.dom;
                    dom.second.innerHTML = _timeDiff[3];
                    dom.minute.innerHTML = _timeDiff[2];
                    dom.hour.innerHTML = _timeDiff[1];
                    dom.day.innerHTML = _timeDiff[0];
                },
                calcDesc:function(){
                    new Request.HTML({
                            url:'<{link app=business ctl=site_member act=js_function_do_refund_pass}>',
                            method:'post',
                            data:'return_id=<{$return_products.0.return_id}>&order_id=<{$return_item.order_id}>'
                    }).send();
                    $clear(this.s);
                    $('timecount').innerHTML='<p>自动同意申请！</p>';
                    $('scarebuyingprice').display='none';
                    $('scarebuyingsucc').display='';
                    return;
                }
            }
        })();
        (function(){
            var timeNow;
            var timeEnd= new Date(<{$time_do_return}>);
            var dom = {
                second: $E('.second'),
                minute:$E('.minute'),
                hour:$E('.hour'),
                day:$E('.day')
            };
            new Request({
                url:'<{$scarebuyings_data.js_url}>',
                onComplete:function(re){
                    timeNow=new Date(<{$now_time_do_return}>); 
                    if(timeEnd.getTime() > timeNow.getTime()){
                        timeCount.init(timeEnd,timeNow,dom);
                    }else{
                        
                    }
                }
            }).send();
        })();
     </script>
    <{else}>
        <script>
        (function() {
            var timestamp_statues = (new Date()).valueOf();
            var timeCount=timestamp_statues;
            var timeCount = this.timeCount = {
                init:function(nowtime,endtime,dom){
                    var diff = Math.abs((nowtime.getTime() - endtime.getTime())/1000);
                    var secondDiff = diff % 60;
                    var minuteDiff = ((diff - secondDiff)/60) % 60;
                    var hourDiff = ((diff - secondDiff  - minuteDiff*60)/3600) % 24;
                    var dayDiff = (diff - secondDiff  - minuteDiff*60 - hourDiff*3600) / 86400;
                    var timeDiff = [dayDiff,hourDiff,minuteDiff,secondDiff];
                    this.s = (function(){this.calcTime.periodical(1000,this,{
                            time:timeDiff,
                            dom:dom
                        })}).delay(100,this);
                },
                addZero:function(timeDiff){
                    for(var i=0;i<timeDiff.length;i++){
                        if(timeDiff[i].toString().length<2){
                            timeDiff[i] = "0" + timeDiff[i].toString();
                            return timeDiff;
                        }
                    }
                },
                formatToInt : function(timeDiff){
                    for(var i=0;i<timeDiff.length;i++){
                        parseInt(timeDiff[i]);
                    };
                    return timeDiff;
                },
                judgeTime : function(timeDiff){
                    if(timeDiff[3]< 0  && timeDiff[2]>0){
                        timeDiff[3] = 59;
                        timeDiff[2]--;
                        return timeDiff;
                    }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]>0){
                        timeDiff[3] = 59
                        timeDiff[2] = 59;
                        timeDiff[1]--;
                        return timeDiff;
                    }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]>0){
                        timeDiff[3] = 59
                        timeDiff[2] = 59;
                        timeDiff[1] = 23;
                        timeDiff[0]--;
                        return timeDiff;
                    }else if(timeDiff[3]==0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]==0){
                        new Request.HTML({
                                url:'<{link app=business ctl=site_member act=js_function_do_agrees}>',
                                method:'post',
                                data:'return_id=<{$return_products.0.return_id}>&order_id=<{$return_item.order_id}>'
                        }).send();
                        $clear(this.s);
                        $('timecount').innerHTML='<p>自动同意申请！</p>';
                        $('scarebuyingprice').display='none';
                        $('scarebuyingsucc').display='';
                        return;
                    }
                },
                calcTime : function (obj){
                    if(!obj.dom) return;
                    var _timeDiff = obj.time;
                    this.addZero(_timeDiff);
                    this.formatToInt(_timeDiff);
                    _timeDiff[3]--;
                    this.judgeTime(_timeDiff);
                    this.addZero(_timeDiff);
                    var dom = obj.dom;
                    dom.second.innerHTML = _timeDiff[3];
                    dom.minute.innerHTML = _timeDiff[2];
                    dom.hour.innerHTML = _timeDiff[1];
                    dom.day.innerHTML = _timeDiff[0];
                },
                calcDesc:function(){
                    new Request.HTML({
                            url:'<{link app=business ctl=site_member act=js_function_do_agrees}>',
                            method:'post',
                            data:'return_id=<{$return_products.0.return_id}>&order_id=<{$return_item.order_id}>'
                    }).send();
                    $clear(this.s);
                    $('timecount').innerHTML='<p>自动同意申请！</p>';
                    $('scarebuyingprice').display='none';
                    $('scarebuyingsucc').display='';
                    return;
                }
            }
        })();
        (function(){
            var timeNow;
            var timeEnd= new Date(<{$time_do_return}>);
            var dom = {
                second: $E('.second'),
                minute:$E('.minute'),
                hour:$E('.hour'),
                day:$E('.day')
            };
            new Request({
                url:'<{$scarebuyings_data.js_url}>',
                onComplete:function(re){
                    timeNow=new Date(<{$now_time_do_return}>); 
                    if(timeEnd.getTime() > timeNow.getTime()){
                        timeCount.init(timeEnd,timeNow,dom);
                    }else{
                        new Request.HTML({
                                url:'<{link app=business ctl=site_member act=js_function_do_agrees}>',
                                method:'post',
                                data:'return_id=<{$return_products.0.return_id}>&order_id=<{$return_item.order_id}>'
                        }).send();
                    }
                }
            }).send();
        })();
     </script>
    <{/if}>
<{/if}>
<{if $return_item.status == '退款协议等待卖家确认' && $return_item.refund_type == '1'}>
<script>
    (function() {
        var timestamp_statues = (new Date()).valueOf();
        var timeCount=timestamp_statues;
        var timeCount = this.timeCount = {
            init:function(nowtime,endtime,dom){
                var diff = Math.abs((nowtime.getTime() - endtime.getTime())/1000);
                var secondDiff = diff % 60;
                var minuteDiff = ((diff - secondDiff)/60) % 60;
                var hourDiff = ((diff - secondDiff  - minuteDiff*60)/3600) % 24;
                var dayDiff = (diff - secondDiff  - minuteDiff*60 - hourDiff*3600) / 86400;
                var timeDiff = [dayDiff,hourDiff,minuteDiff,secondDiff];
                this.s = (function(){this.calcTime.periodical(1000,this,{
                        time:timeDiff,
                        dom:dom
                    })}).delay(100,this);
            },
            addZero:function(timeDiff){
                for(var i=0;i<timeDiff.length;i++){
                    if(timeDiff[i].toString().length<2){
                        timeDiff[i] = "0" + timeDiff[i].toString();
                        return timeDiff;
                    }
                }
            },
            formatToInt : function(timeDiff){
                for(var i=0;i<timeDiff.length;i++){
                    parseInt(timeDiff[i]);
                };
                return timeDiff;
            },
            judgeTime : function(timeDiff){
                if(timeDiff[3]< 0  && timeDiff[2]>0){
                    timeDiff[3] = 59;
                    timeDiff[2]--;
                    return timeDiff;
                }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]>0){
                    timeDiff[3] = 59
                    timeDiff[2] = 59;
                    timeDiff[1]--;
                    return timeDiff;
                }else if(timeDiff[3] <0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]>0){
                    timeDiff[3] = 59
                    timeDiff[2] = 59;
                    timeDiff[1] = 23;
                    timeDiff[0]--;
                    return timeDiff;
                }else if(timeDiff[3]==0 && timeDiff[2]==0 && timeDiff[1]==0 && timeDiff[0]==0){
                    new Request.HTML({
                            url:'<{link app=business ctl=site_member act=js_function_do_agree}>',
                            method:'post',
                            data:'return_id=<{$return_products.0.return_id}>&order_id=<{$return_item.order_id}>'
                    }).send();
                    $clear(this.s);
                    $('timecount').innerHTML='<p>自动同意申请！</p>';
                    $('scarebuyingprice').display='none';
                    $('scarebuyingsucc').display='';
                    return;
                }
            },
            calcTime : function (obj){
                if(!obj.dom) return;
                var _timeDiff = obj.time;
                this.addZero(_timeDiff);
                this.formatToInt(_timeDiff);
                _timeDiff[3]--;
                this.judgeTime(_timeDiff);
                this.addZero(_timeDiff);
                var dom = obj.dom;
                dom.second.innerHTML = _timeDiff[3];
                dom.minute.innerHTML = _timeDiff[2];
                dom.hour.innerHTML = _timeDiff[1];
                dom.day.innerHTML = _timeDiff[0];
            },
            calcDesc:function(){
                new Request.HTML({
                        url:'<{link app=business ctl=site_member act=js_function_do_agree}>',
                        method:'post',
                        data:'return_id=<{$return_products.0.return_id}>&order_id=<{$return_item.order_id}>'
                }).send();
                $clear(this.s);
                $('timecount').innerHTML='<p>自动同意申请！</p>';
                $('scarebuyingprice').display='none';
                $('scarebuyingsucc').display='';
                return;
            }
        }
    })();
    (function(){
        var timeNow;
        var timeEnd= new Date(<{$time_do_return}>);
        var dom = {
            second: $E('.second'),
            minute:$E('.minute'),
            hour:$E('.hour'),
            day:$E('.day')
        };
        new Request({
            url:'<{$scarebuyings_data.js_url}>',
            onComplete:function(re){
                timeNow=new Date(<{$now_time_do_return}>); 
                if(timeEnd.getTime() > timeNow.getTime()){
                    timeCount.init(timeEnd,timeNow,dom);
                }else{
                    
                }
            }
        }).send();
    })();
 </script>
<{/if}>